package com.xqyq.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



import com.xqyq.dao.MatchDao;
import com.xqyq.model.Match;

@Service
public class MatchService {
	@Autowired
	private MatchDao matchDao;
	
	
	@Transactional
	public boolean addMatch(Match match){
		return matchDao.addMatch(match);
	}
	
	public void updateMatch(Match match){
		matchDao.updateMatch(match);
	}
	
	public List<Match> getAllMatch(){
		return matchDao.getAllMatch();
	}
	
	public Match getTheWholeMatch(int match_id){
		Match match = matchDao.getMatch(match_id);
		System.out.println(match.getMatch_content().getContent_id());
		return match;
	}
	
	public void changeMatchState(int match_id, int state){
		matchDao.changeMatchState(match_id, state);
	}
	
	public void deleteMatch(int match_id){
		matchDao.deleteMatch(match_id);
	}
	
	public List<Match> getPublishMatch(int limit){
		return matchDao.getPublishMatch(limit);
	}
	
	public Match getMatchWithSign(int match_id){
		Match match = matchDao.getMatch(match_id);
		//System.out.println(match.getSigns().size());
		return match;
	}
	
	public Match getMatch(int match_id){
		return matchDao.getMatch(match_id);
	}
	
	public List<Match> getEndMatch(){
		return matchDao.getEndMatch();
	}
	
}
